/**
 * 题目相关的公共组件
 */
import { getTargetTeamList } from '@/api/drill_compete'

export default {
    data() {
        return {
            questionList: []
        }
    },
    mounted() {
        this.getQuestionList()
    },
    methods: {
        getQuestionList(){
            let sceneId = this.$route.query.id
            let projectId = this.$route.query.prjid
            if(!sceneId || !projectId){
                return;
            }
            let params = {
                pageIndex:1,
                pageSize:2147483647,
                sceneId: sceneId,
                projectId: projectId
            }
            getTargetTeamList(params).then(({ code, data, message }) => {
                if(code === 1){
                    this.questionList = data.items;
                }else if(data.code == -2) {
                    this.questionList = [];
                }else{
                    this.$Message.warning(message);
                }
            })
        },
        getQuestionNameById(id) {
            let question = this.questionList.find(item => {
                return item.id === id
            })
            return question ? question.name : ''
        }
    }
}